.class public Lcom/openfeint/internal/Util;
.super Ljava/lang/Object;
.source "Util.java"


# static fields
.field private static final TAG:Ljava/lang/String; = "Util"

.field public static final VERSION:I


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 29
    sget-object v0, Landroid/os/Build$VERSION;->SDK:Ljava/lang/String;

    invoke-static {v0}, Ljava/lang/Integer;->valueOf(Ljava/lang/String;)Ljava/lang/Integer;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v0

    sput v0, Lcom/openfeint/internal/Util;->VERSION:I

    .line 27
    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 27
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static copyDirectory(Ljava/io/File;Ljava/io/File;)V
    .locals 5
    .parameter "srcDir"
    .parameter "dstDir"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 69
    invoke-virtual {p0}, Ljava/io/File;->isDirectory()Z

    move-result v2

    if-eqz v2, :cond_2

    .line 70
    invoke-virtual {p1}, Ljava/io/File;->exists()Z

    move-result v2

    if-nez v2, :cond_0

    .line 71
    invoke-virtual {p1}, Ljava/io/File;->mkdir()Z

    .line 74
    :cond_0
    invoke-virtual {p0}, Ljava/io/File;->list()[Ljava/lang/String;

    move-result-object v0

    .line 75
    .local v0, children:[Ljava/lang/String;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    array-length v2, v0

    if-lt v1, v2, :cond_1

    .line 83
    .end local v0           #children:[Ljava/lang/String;
    .end local v1           #i:I
    :goto_1
    return-void

    .line 76
    .restart local v0       #children:[Ljava/lang/String;
    .restart local v1       #i:I
    :cond_1
    new-instance v2, Ljava/io/File;

    aget-object v3, v0, v1

    invoke-direct {v2, p0, v3}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 77
    new-instance v3, Ljava/io/File;

    aget-object v4, v0, v1

    invoke-direct {v3, p1, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 76
    invoke-static {v2, v3}, Lcom/openfeint/internal/Util;->copyDirectory(Ljava/io/File;Ljava/io/File;)V

    .line 75
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 81
    .end local v0           #children:[Ljava/lang/String;
    .end local v1           #i:I
    :cond_2
    invoke-static {p0, p1}, Lcom/openfeint/internal/Util;->copyFile(Ljava/io/File;Ljava/io/File;)V

    goto :goto_1
.end method

.method public static copyFile(Ljava/io/File;Ljava/io/File;)V
    .locals 2
    .parameter "src"
    .parameter "dst"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 86
    new-instance v0, Ljava/io/FileInputStream;

    invoke-direct {v0, p0}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    .line 87
    .local v0, in:Ljava/io/InputStream;
    new-instance v1, Ljava/io/FileOutputStream;

    invoke-direct {v1, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 88
    .local v1, out:Ljava/io/OutputStream;
    invoke-static {v0, v1}, Lcom/openfeint/internal/Util;->copyStream(Ljava/io/InputStream;Ljava/io/OutputStream;)V

    .line 89
    return-void
.end method

.method public static copyStream(Ljava/io/InputStream;Ljava/io/OutputStream;)V
    .locals 0
    .parameter "in"
    .parameter "out"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 102
    invoke-static {p0, p1}, Lcom/openfeint/internal/Util;->copyStreamAndLeaveInputOpen(Ljava/io/InputStream;Ljava/io/OutputStream;)V

    .line 103
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V

    .line 104
    return-void
.end method

.method public static copyStreamAndLeaveInputOpen(Ljava/io/InputStream;Ljava/io/OutputStream;)V
    .locals 3
    .parameter "in"
    .parameter "out"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 94
    const/16 v2, 0x4000

    new-array v0, v2, [B

    .line 95
    .local v0, copyBuffer:[B
    :goto_0
    invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I

    move-result v1

    .local v1, len:I
    if-gtz v1, :cond_0

    .line 98
    invoke-virtual {p1}, Ljava/io/OutputStream;->close()V

    .line 99
    return-void

    .line 96
    :cond_0
    const/4 v2, 0x0

    invoke-virtual {p1, v0, v2, v1}, Ljava/io/OutputStream;->write([BII)V

    goto :goto_0
.end method

.method public static createSymbolic(Ljava/lang/String;Ljava/lang/String;)V
    .locals 2
    .parameter "dst"
    .parameter "src"

    .prologue
    .line 144
    new-instance v0, Ljava/lang/StringBuilder;

    const-string v1, "ln -s "

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string v1, " "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-static {v0}, Lcom/openfeint/internal/Util;->run(Ljava/lang/String;)V

    .line 145
    return-void
.end method

.method public static deleteFiles(Ljava/io/File;)V
    .locals 5
    .parameter "path"

    .prologue
    .line 56
    invoke-virtual {p0}, Ljava/io/File;->isDirectory()Z

    move-result v3

    if-eqz v3, :cond_0

    .line 57
    invoke-virtual {p0}, Ljava/io/File;->list()[Ljava/lang/String;

    move-result-object v1

    .line 58
    .local v1, files:[Ljava/lang/String;
    array-length v3, v1

    const/4 v4, 0x0

    :goto_0
    if-lt v4, v3, :cond_1

    .line 63
    .end local v1           #files:[Ljava/lang/String;
    :cond_0
    invoke-virtual {p0}, Ljava/io/File;->delete()Z

    .line 64
    return-void

    .line 58
    .restart local v1       #files:[Ljava/lang/String;
    :cond_1
    aget-object v2, v1, v4

    .line 59
    .local v2, name:Ljava/lang/String;
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p0, v2}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 60
    .local v0, child:Ljava/io/File;
    invoke-static {v0}, Lcom/openfeint/internal/Util;->deleteFiles(Ljava/io/File;)V

    .line 58
    add-int/lit8 v4, v4, 0x1

    goto :goto_0
.end method

.method public static getDisplayMetrics()Landroid/util/DisplayMetrics;
    .locals 4

    .prologue
    .line 127
    new-instance v0, Landroid/util/DisplayMetrics;

    invoke-direct {v0}, Landroid/util/DisplayMetrics;-><init>()V

    .line 128
    .local v0, metrics:Landroid/util/DisplayMetrics;
    invoke-static {}, Lcom/openfeint/internal/OpenFeintInternal;->getInstance()Lcom/openfeint/internal/OpenFeintInternal;

    move-result-object v2

    invoke-virtual {v2}, Lcom/openfeint/internal/OpenFeintInternal;->getContext()Landroid/content/Context;

    move-result-object v2

    const-string v3, "window"

    invoke-virtual {v2, v3}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/view/WindowManager;

    .line 129
    .local v1, wm:Landroid/view/WindowManager;
    invoke-interface {v1}, Landroid/view/WindowManager;->getDefaultDisplay()Landroid/view/Display;

    move-result-object v2

    invoke-virtual {v2, v0}, Landroid/view/Display;->getMetrics(Landroid/util/DisplayMetrics;)V

    .line 130
    return-object v0
.end method

.method public static getDpiName(Landroid/content/Context;)Ljava/lang/String;
    .locals 6
    .parameter "ctx"

    .prologue
    .line 249
    new-instance v0, Landroid/util/DisplayMetrics;

    invoke-direct {v0}, Landroid/util/DisplayMetrics;-><init>()V

    .line 250
    .local v0, metrics:Landroid/util/DisplayMetrics;
    const-string v2, "window"

    invoke-virtual {p0, v2}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Landroid/view/WindowManager;

    .line 251
    .local v1, winMan:Landroid/view/WindowManager;
    invoke-interface {v1}, Landroid/view/WindowManager;->getDefaultDisplay()Landroid/view/Display;

    move-result-object v2

    invoke-virtual {v2, v0}, Landroid/view/Display;->getMetrics(Landroid/util/DisplayMetrics;)V

    .line 252
    iget v2, v0, Landroid/util/DisplayMetrics;->density:F

    const/high16 v3, 0x4000

    cmpl-float v2, v2, v3

    if-ltz v2, :cond_0

    .line 253
    const-string v2, "udpi"

    .line 257
    :goto_0
    return-object v2

    .line 254
    :cond_0
    iget v2, v0, Landroid/util/DisplayMetrics;->density:F

    float-to-double v2, v2

    const-wide/high16 v4, 0x3ff8

    cmpl-double v2, v2, v4

    if-ltz v2, :cond_1

    .line 255
    const-string v2, "hdpi"

    goto :goto_0

    .line 257
    :cond_1
    const-string v2, "mdpi"

    goto :goto_0
.end method

.method public static getObjFromJson([B)Ljava/lang/Object;
    .locals 6
    .parameter "json"

    .prologue
    .line 224
    new-instance v3, Lorg/codehaus/jackson/JsonFactory;

    invoke-direct {v3}, Lorg/codehaus/jackson/JsonFactory;-><init>()V

    .line 226
    .local v3, jsonFactory:Lorg/codehaus/jackson/JsonFactory;
    :try_start_0
    invoke-virtual {v3, p0}, Lorg/codehaus/jackson/JsonFactory;->createJsonParser([B)Lorg/codehaus/jackson/JsonParser;

    move-result-object v1

    .line 227
    .local v1, jp:Lorg/codehaus/jackson/JsonParser;
    new-instance v2, Lcom/openfeint/internal/JsonResourceParser;

    invoke-direct {v2, v1}, Lcom/openfeint/internal/JsonResourceParser;-><init>(Lorg/codehaus/jackson/JsonParser;)V

    .line 228
    .local v2, jrp:Lcom/openfeint/internal/JsonResourceParser;
    invoke-virtual {v2}, Lcom/openfeint/internal/JsonResourceParser;->parse()Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v4

    .line 232
    .end local v1           #jp:Lorg/codehaus/jackson/JsonParser;
    .end local v2           #jrp:Lcom/openfeint/internal/JsonResourceParser;
    :goto_0
    return-object v4

    .line 229
    :catch_0
    move-exception v4

    move-object v0, v4

    .line 230
    .local v0, e:Ljava/lang/Exception;
    const-string v4, "Util"

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Lcom/openfeint/internal/OpenFeintInternal;->log(Ljava/lang/String;Ljava/lang/String;)V

    .line 232
    const/4 v4, 0x0

    goto :goto_0
.end method

.method public static getObjFromJson([BLcom/openfeint/internal/resource/ResourceClass;)Ljava/lang/Object;
    .locals 7
    .parameter "json"
    .parameter "resourceClass"

    .prologue
    .line 236
    new-instance v3, Lorg/codehaus/jackson/JsonFactory;

    invoke-direct {v3}, Lorg/codehaus/jackson/JsonFactory;-><init>()V

    .line 237
    .local v3, jsonFactory:Lorg/codehaus/jackson/JsonFactory;
    const-string v4, "Util"

    new-instance v5, Ljava/lang/String;

    invoke-direct {v5, p0}, Ljava/lang/String;-><init>([B)V

    invoke-static {v4, v5}, Lcom/openfeint/internal/OpenFeintInternal;->log(Ljava/lang/String;Ljava/lang/String;)V

    .line 239
    :try_start_0
    invoke-virtual {v3, p0}, Lorg/codehaus/jackson/JsonFactory;->createJsonParser([B)Lorg/codehaus/jackson/JsonParser;

    move-result-object v1

    .line 240
    .local v1, jp:Lorg/codehaus/jackson/JsonParser;
    new-instance v2, Lcom/openfeint/internal/JsonResourceParser;

    invoke-direct {v2, v1}, Lcom/openfeint/internal/JsonResourceParser;-><init>(Lorg/codehaus/jackson/JsonParser;)V

    .line 241
    .local v2, jrp:Lcom/openfeint/internal/JsonResourceParser;
    invoke-virtual {v2, p1}, Lcom/openfeint/internal/JsonResourceParser;->parse(Lcom/openfeint/internal/resource/ResourceClass;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v4

    .line 245
    .end local v1           #jp:Lorg/codehaus/jackson/JsonParser;
    .end local v2           #jrp:Lcom/openfeint/internal/JsonResourceParser;
    :goto_0
    return-object v4

    .line 242
    :catch_0
    move-exception v4

    move-object v0, v4

    .line 243
    .local v0, e:Ljava/lang/Exception;
    const-string v4, "Util"

    new-instance v5, Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v6

    invoke-static {v6}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v6

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v6, "json error"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v4, v5}, Lcom/openfeint/internal/OpenFeintInternal;->log(Ljava/lang/String;Ljava/lang/String;)V

    .line 245
    const/4 v4, 0x0

    goto :goto_0
.end method

.method public static getObjFromJsonFile(Ljava/lang/String;)Ljava/lang/Object;
    .locals 2
    .parameter "path"

    .prologue
    .line 207
    :try_start_0
    new-instance v0, Ljava/io/FileInputStream;

    new-instance v1, Ljava/io/File;

    invoke-direct {v1, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-direct {v0, v1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    .line 208
    .local v0, in:Ljava/io/InputStream;
    invoke-static {v0}, Lcom/openfeint/internal/Util;->getObjFromJsonStream(Ljava/io/InputStream;)Ljava/lang/Object;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v1

    .line 211
    .end local v0           #in:Ljava/io/InputStream;
    :goto_0
    return-object v1

    .line 209
    :catch_0
    move-exception v1

    .line 211
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static getObjFromJsonStream(Ljava/io/InputStream;)Ljava/lang/Object;
    .locals 4
    .parameter "in"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/codehaus/jackson/JsonParseException;,
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 215
    new-instance v2, Lorg/codehaus/jackson/JsonFactory;

    invoke-direct {v2}, Lorg/codehaus/jackson/JsonFactory;-><init>()V

    .line 216
    .local v2, jsonFactory:Lorg/codehaus/jackson/JsonFactory;
    invoke-virtual {v2, p0}, Lorg/codehaus/jackson/JsonFactory;->createJsonParser(Ljava/io/InputStream;)Lorg/codehaus/jackson/JsonParser;

    move-result-object v0

    .line 217
    .local v0, jp:Lorg/codehaus/jackson/JsonParser;
    new-instance v1, Lcom/openfeint/internal/JsonResourceParser;

    invoke-direct {v1, v0}, Lcom/openfeint/internal/JsonResourceParser;-><init>(Lorg/codehaus/jackson/JsonParser;)V

    .line 218
    .local v1, jrp:Lcom/openfeint/internal/JsonResourceParser;
    invoke-virtual {v1}, Lcom/openfeint/internal/JsonResourceParser;->parse()Ljava/lang/Object;

    move-result-object v3

    .line 219
    .local v3, obj:Ljava/lang/Object;
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V

    .line 220
    return-object v3
.end method

.method public static isPadVersion()Z
    .locals 2

    .prologue
    .line 32
    sget v0, Lcom/openfeint/internal/Util;->VERSION:I

    const/16 v1, 0xb

    if-lt v0, v1, :cond_0

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public static isSymblic(Ljava/io/File;)Z
    .locals 3
    .parameter "f"

    .prologue
    const/4 v2, 0x0

    .line 149
    :try_start_0
    invoke-virtual {p0}, Ljava/io/File;->getCanonicalPath()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v0

    if-eqz v0, :cond_0

    move v0, v2

    .line 152
    :goto_0
    return v0

    .line 149
    :cond_0
    const/4 v0, 0x1

    goto :goto_0

    .line 150
    :catch_0
    move-exception v0

    move v0, v2

    .line 152
    goto :goto_0
.end method

.method public static moveWebCache(Landroid/content/Context;)V
    .locals 5
    .parameter "ctx"

    .prologue
    .line 165
    invoke-static {p0}, Lcom/openfeint/internal/Util;->noSdcardPermission(Landroid/content/Context;)Z

    move-result v3

    if-nez v3, :cond_1

    .line 181
    :cond_0
    :goto_0
    return-void

    .line 166
    :cond_1
    new-instance v0, Ljava/io/File;

    invoke-virtual {p0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v3

    const-string v4, "webviewCache"

    invoke-direct {v0, v3, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 168
    .local v0, cache:Ljava/io/File;
    invoke-static {v0}, Lcom/openfeint/internal/Util;->isSymblic(Ljava/io/File;)Z

    move-result v3

    if-nez v3, :cond_0

    .line 171
    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v2

    .line 172
    .local v2, state:Ljava/lang/String;
    const-string v3, "mounted"

    invoke-virtual {v3, v2}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v3

    if-eqz v3, :cond_0

    .line 175
    new-instance v1, Ljava/io/File;

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v3

    const-string v4, "openfeint/cache"

    invoke-direct {v1, v3, v4}, Ljava/io/File;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 176
    .local v1, sdcard:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v3

    if-nez v3, :cond_2

    .line 177
    invoke-virtual {v1}, Ljava/io/File;->mkdirs()Z

    .line 179
    :cond_2
    invoke-static {v0}, Lcom/openfeint/internal/Util;->deleteFiles(Ljava/io/File;)V

    .line 180
    invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v0}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v4

    invoke-static {v3, v4}, Lcom/openfeint/internal/Util;->createSymbolic(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0
.end method

.method public static noPermission(Ljava/lang/String;Landroid/content/Context;)Z
    .locals 3
    .parameter "permission"
    .parameter "ctx"

    .prologue
    .line 184
    const/4 v0, -0x1

    invoke-virtual {p1}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v1

    .line 185
    invoke-virtual {p1}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v2

    .line 184
    invoke-virtual {v1, p0, v2}, Landroid/content/pm/PackageManager;->checkPermission(Ljava/lang/String;Ljava/lang/String;)I

    move-result v1

    if-ne v0, v1, :cond_0

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public static noSdcardPermission()Z
    .locals 1

    .prologue
    .line 189
    invoke-static {}, Lcom/openfeint/internal/OpenFeintInternal;->getInstance()Lcom/openfeint/internal/OpenFeintInternal;

    move-result-object v0

    invoke-virtual {v0}, Lcom/openfeint/internal/OpenFeintInternal;->getContext()Landroid/content/Context;

    move-result-object v0

    invoke-static {v0}, Lcom/openfeint/internal/Util;->noSdcardPermission(Landroid/content/Context;)Z

    move-result v0

    return v0
.end method

.method public static noSdcardPermission(Landroid/content/Context;)Z
    .locals 1
    .parameter "ctx"

    .prologue
    .line 193
    const-string v0, "android.permission.WRITE_EXTERNAL_STORAGE"

    invoke-static {v0, p0}, Lcom/openfeint/internal/Util;->noPermission(Ljava/lang/String;Landroid/content/Context;)Z

    move-result v0

    return v0
.end method

.method public static readWholeFile(Ljava/lang/String;)[B
    .locals 6
    .parameter "path"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 197
    new-instance v1, Ljava/io/File;

    invoke-direct {v1, p0}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 198
    .local v1, f:Ljava/io/File;
    invoke-virtual {v1}, Ljava/io/File;->length()J

    move-result-wide v4

    long-to-int v3, v4

    .line 199
    .local v3, len:I
    new-instance v2, Ljava/io/FileInputStream;

    invoke-direct {v2, v1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    .line 200
    .local v2, in:Ljava/io/InputStream;
    new-array v0, v3, [B

    .line 201
    .local v0, b:[B
    invoke-virtual {v2, v0}, Ljava/io/InputStream;->read([B)I

    .line 202
    invoke-virtual {v2}, Ljava/io/InputStream;->close()V

    .line 203
    return-object v0
.end method

.method public static run(Ljava/lang/String;)V
    .locals 3
    .parameter "cmd"

    .prologue
    .line 135
    :try_start_0
    invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime;

    move-result-object v1

    invoke-virtual {v1, p0}, Ljava/lang/Runtime;->exec(Ljava/lang/String;)Ljava/lang/Process;

    .line 136
    const-string v1, "Util"

    invoke-static {v1, p0}, Lcom/openfeint/internal/OpenFeintInternal;->log(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 141
    :goto_0
    return-void

    .line 138
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 139
    .local v0, e:Ljava/lang/Exception;
    const-string v1, "Util"

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v2

    invoke-static {v1, v2}, Lcom/openfeint/internal/OpenFeintInternal;->log(Ljava/lang/String;Ljava/lang/String;)V

    goto :goto_0
.end method

.method public static saveFile([BLjava/lang/String;)V
    .locals 3
    .parameter "in"
    .parameter "path"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 107
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 108
    .local v0, file:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/File;->mkdirs()Z

    .line 109
    new-instance v1, Ljava/io/FileOutputStream;

    invoke-direct {v1, v0}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 110
    .local v1, out:Ljava/io/FileOutputStream;
    invoke-virtual {v1, p0}, Ljava/io/FileOutputStream;->write([B)V

    .line 111
    invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V

    .line 112
    return-void
.end method

.method public static saveStream(Ljava/io/InputStream;Ljava/lang/String;)V
    .locals 0
    .parameter "in"
    .parameter "path"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 122
    invoke-static {p0, p1}, Lcom/openfeint/internal/Util;->saveStreamAndLeaveInputOpen(Ljava/io/InputStream;Ljava/lang/String;)V

    .line 123
    invoke-virtual {p0}, Ljava/io/InputStream;->close()V

    .line 124
    return-void
.end method

.method public static saveStreamAndLeaveInputOpen(Ljava/io/InputStream;Ljava/lang/String;)V
    .locals 3
    .parameter "in"
    .parameter "path"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 115
    new-instance v0, Ljava/io/File;

    invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 116
    .local v0, file:Ljava/io/File;
    invoke-virtual {v0}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v2

    invoke-virtual {v2}, Ljava/io/File;->mkdirs()Z

    .line 117
    new-instance v1, Ljava/io/FileOutputStream;

    invoke-direct {v1, v0}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 118
    .local v1, out:Ljava/io/FileOutputStream;
    invoke-static {p0, v1}, Lcom/openfeint/internal/Util;->copyStreamAndLeaveInputOpen(Ljava/io/InputStream;Ljava/io/OutputStream;)V

    .line 119
    return-void
.end method

.method public static sdcardReady(Landroid/content/Context;)Z
    .locals 3
    .parameter "ctx"

    .prologue
    const/4 v2, 0x0

    .line 156
    invoke-static {p0}, Lcom/openfeint/internal/Util;->noSdcardPermission(Landroid/content/Context;)Z

    move-result v1

    if-nez v1, :cond_0

    move v1, v2

    .line 161
    :goto_0
    return v1

    .line 157
    :cond_0
    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v0

    .line 158
    .local v0, state:Ljava/lang/String;
    const-string v1, "mounted"

    invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v1

    if-nez v1, :cond_1

    move v1, v2

    .line 159
    goto :goto_0

    .line 161
    :cond_1
    const/4 v1, 0x1

    goto :goto_0
.end method

.method public static setOrientation(Landroid/app/Activity;)V
    .locals 3
    .parameter "act"

    .prologue
    .line 36
    invoke-static {}, Lcom/openfeint/internal/OpenFeintInternal;->getInstance()Lcom/openfeint/internal/OpenFeintInternal;

    move-result-object v1

    invoke-virtual {v1}, Lcom/openfeint/internal/OpenFeintInternal;->getSettings()Ljava/util/Map;

    move-result-object v1

    const-string v2, "RequestedOrientation"

    invoke-interface {v1, v2}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Integer;

    .line 38
    .local v0, orientation:Ljava/lang/Integer;
    if-eqz v0, :cond_0

    .line 39
    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v1

    invoke-virtual {p0, v1}, Landroid/app/Activity;->setRequestedOrientation(I)V

    .line 41
    :cond_0
    return-void
.end method

.method public static final toByteArray(Ljava/io/InputStream;)[B
    .locals 5
    .parameter "is"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 44
    const/16 v0, 0x1000

    .line 45
    .local v0, CHUNK_SIZE:I
    const/16 v4, 0x1000

    new-array v3, v4, [B

    .line 46
    .local v3, readBuffer:[B
    new-instance v1, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V

    .line 48
    .local v1, accumulator:Ljava/io/ByteArrayOutputStream;
    :goto_0
    invoke-virtual {p0, v3}, Ljava/io/InputStream;->read([B)I

    move-result v2

    .local v2, count:I
    if-gtz v2, :cond_0

    .line 51
    invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->close()V

    .line 52
    invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v4

    return-object v4

    .line 49
    :cond_0
    const/4 v4, 0x0

    invoke-virtual {v1, v3, v4, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    goto :goto_0
.end method
